package jm.demo.gsp;


public class GSPDemo {
/*
	public static void initRequestContext(GroovyPagesTemplateEngine template_engine) {
		MockServletContext context = new MockServletContext();
		template_engine.setServletContext(context);
		HttpServletRequest request = new MockHttpServletRequest();
		// request.setAttribute(REQUEST_ATTRIBUTES_ATTRIBUTE, attributes);
		LocaleContextHolder.setLocale(request.getLocale());
		GrailsWebRequest grails_request = new GrailsWebRequest(request, new MockHttpServletResponse(), context);
		RequestContextHolder.setRequestAttributes(grails_request);	
		
		System.out.println(GrailsUtil.getGrailsVersion());
	}
	
	public static void main(String[] args) {
		GroovyPagesTemplateEngine template_engine = new GroovyPagesTemplateEngine();

		initRequestContext(template_engine);
		// StringReader reader = new StringReader("<h1>Trip List</h1><if test=\"${flash.message}\"><div class=message>${flash.message}</div></g:if>");
		// StringReader reader = new StringReader("<h1>Trip List</h1><if test=><div class=message></div>");
		StringReader reader = new StringReader("abc");
		StringWriter writer = new StringWriter();
		try {
			Template template = template_engine.createTemplate(reader);
			
			System.out.println(template.toString());
			
			// Writable writable = template.make(ImmutableMap.of("flash", ImmutableMap.of("message", "Hi jiming")));
			Writable writable = template.make();
			writable.writeTo(writer);
			System.out.println(writer.toString());
			
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	*/
}
